<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    //生成器就是一个特殊的函数
    //异步编程 纯回调函数

    function * gen() {
        console.log('hello')
    }
    let iterator = gen().next() //hello

    //函数代码的分隔符
    function * gen1() {
        console.log('hello1')
        yield '1111';
        console.log('hello2')
        yield '2222';
        console.log('hello3')
        yield '3333';
        console.log('hello4')
    }
    let iterator1 = gen1();
    iterator1.next();//hello1 done:false
    iterator1.next();//hello2 done:false
    iterator1.next();//hello3 done:false
    iterator1.next();//hello4 done:false

    for(let v of gen1()){
        console.log(v) //1111 hello1 一次遍历
    }


</script>
</body>
</html>